<?php

class StrArray extends ArrayObject {
	
	private $glue = '';
	
	public function __construct($arg=null) {
		if (is_array($arg)) {
			parent::__construct($arg);
		}
		else {
			parent::__construct();
			if ($arg !== null) {
				$this->glue = $arg;
			}
		}
	}
	
	public function get_glue() {
		return $this->glue;
	}
	
	public function set_glue($glue) {
		$this->glue = $glue;
	}
	
	public function __toString() {
		$stringified = array();
		foreach ($this as $value) { // ->getArrayCopy()
			if (method_exists($value, '__toString')) {
				$stringified[] = $value->__toString(); 
			}
			else {
				$stringified[] = $value; 
			}
		}
		return implode($this->glue, $stringified);
	}
	
}

?>